package com.app.service.authority;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.app.entity.authority.Department;
import com.app.mapper.authority.DepartmentMapper;

import java.util.List;

/**
 * 
 * @author zhangyufei
 *  �˵�����ҳ��
 */
@Service
public class DepartmentService {
	
	
	  private final static Logger logger = LoggerFactory.getLogger(DepartmentService.class);

		@Autowired
		DepartmentMapper departmentMapper;
	     
//		/**
//		 * ��������
//		 * @return
//		 */
//		public Department insertDepartment(Department department) {
//			return departmentMapper.insertDepartment(department);
//		}
//		/**
//		 * ɾ������
//		 * @return
//		 */
//		public Department deleteDepartment(Department department) {
//			return  departmentMapper.deleteDepartment(department);
//		}
//		/**
//		 * �޸�����
//		 * @return
//		 */
//		public Department updateDepartment(Department department) {
//			return departmentMapper.updateDepartment(department);
//		}
//		/**
//		 * ��ѯ����
//		 * @param department
//		 * @return
//		 */
//		public Department queryDepartment(String parent_id) {
//			return departmentMapper.selectDepartment(parent_id);
//		}

	public List<Department> getInfoById(String id){
		return departmentMapper.selectDepartmentById(id);
	}
	public List<Department> queryDepartByParentId(String parent_id) {
		logger.info("func:queryDepartByParentId   %nparent_id:" + parent_id);
		List<Department> result = null;
		try {
			result = departmentMapper.selectDepartByParentId(parent_id);


		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public int insertDepartment(Department _department) {

		logger.info("func:insertDepartment%n_department:"+_department.toString());
		int result = -1;
		try {

			result = departmentMapper.insertDepartment(_department);


		} catch (Exception e) {

//			return result;
		}
		return result;

	}


	public  List<Department> queryDepartAll(String  parntId) {
		logger.info("func:insertDepartment%nparntId:"+parntId);

		List<Department> result = null;
		try {

			result = departmentMapper.queryDeptTreeList(parntId);



		} catch (Exception e) {

//			return result;
		}
		return result;
	}

	public  List<Department> validateLevelCode(Department _department){
		logger.info("func:validateLevelCode%n _department:"+  _department );

		List<Department> result = null;
		try {

			result = departmentMapper.validateLevelCode(    _department);



		} catch (Exception e) {

		}
		return result;
	}

	//updateDepart
	public  int updateDepart(Department _department){
		logger.info("func:updateDepart%n _department:"+  _department );

		int result = -1;
		try {

			result = departmentMapper.updateDepart(    _department);


		} catch (Exception e) {

//			return result;
		}
		return result;

	}
	//delDepart
	public  int delDepart(Department _department){
		logger.info("func:delDepart%n _department:"+  _department );

		int result = -1;
		try {


			result = departmentMapper.delDepart(    _department);


		} catch (Exception e) {

//			return result;
		}
		return result;

	}

}
